﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using PAT.Entities;
using PAT.Data;

#endregion

namespace PAT.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PatTiempoTallerProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PatTiempoTallerProviderBaseCore : EntityProviderBase<PAT.Entities.PatTiempoTaller, PAT.Entities.PatTiempoTallerKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, PAT.Entities.PatTiempoTallerKey key)
		{
			return Delete(transactionManager, key.IdGrupoCatalogo, key.IdOperacion);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_idGrupoCatalogo">. Primary Key.</param>
		/// <param name="_idOperacion">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion)
		{
			return Delete(null, _idGrupoCatalogo, _idOperacion);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo">. Primary Key.</param>
		/// <param name="_idOperacion">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(_idGrupoCatalogo, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		/// <remarks></remarks>
		public TList<PatTiempoTaller> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogo(transactionManager, _idGrupoCatalogo, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		fkPatTiempoTallerPatGrupoCatalogo Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		fkPatTiempoTallerPatGrupoCatalogo Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdGrupoCatalogo(System.Int16 _idGrupoCatalogo, int start, int pageLength,out int count)
		{
			return GetByIdGrupoCatalogo(null, _idGrupoCatalogo, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_GRUPO_CATALOGO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public abstract TList<PatTiempoTaller> GetByIdGrupoCatalogo(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO Description: 
		/// </summary>
		/// <param name="_idOperacion"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdOperacion(System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacion(_idOperacion, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		/// <remarks></remarks>
		public TList<PatTiempoTaller> GetByIdOperacion(TransactionManager transactionManager, System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdOperacion(transactionManager, _idOperacion, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdOperacion(TransactionManager transactionManager, System.Int32 _idOperacion, int start, int pageLength)
		{
			int count = -1;
			return GetByIdOperacion(transactionManager, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		fkPatTiempoTallerPatTempario Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdOperacion(System.Int32 _idOperacion, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdOperacion(null, _idOperacion, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		fkPatTiempoTallerPatTempario Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idOperacion"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public TList<PatTiempoTaller> GetByIdOperacion(System.Int32 _idOperacion, int start, int pageLength,out int count)
		{
			return GetByIdOperacion(null, _idOperacion, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO key.
		///		FK_PAT_TIEMPO_TALLER_PAT_TEMPARIO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatTiempoTaller objects.</returns>
		public abstract TList<PatTiempoTaller> GetByIdOperacion(TransactionManager transactionManager, System.Int32 _idOperacion, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override PAT.Entities.PatTiempoTaller Get(TransactionManager transactionManager, PAT.Entities.PatTiempoTallerKey key, int start, int pageLength)
		{
			return GetByIdGrupoCatalogoIdOperacion(transactionManager, key.IdGrupoCatalogo, key.IdOperacion, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdGrupoCatalogoIdOperacion(null,_idGrupoCatalogo, _idOperacion, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogoIdOperacion(null, _idGrupoCatalogo, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion)
		{
			int count = -1;
			return GetByIdGrupoCatalogoIdOperacion(transactionManager, _idGrupoCatalogo, _idOperacion, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion, int start, int pageLength)
		{
			int count = -1;
			return GetByIdGrupoCatalogoIdOperacion(transactionManager, _idGrupoCatalogo, _idOperacion, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion, int start, int pageLength, out int count)
		{
			return GetByIdGrupoCatalogoIdOperacion(null, _idGrupoCatalogo, _idOperacion, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_TIEMPO_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idGrupoCatalogo"></param>
		/// <param name="_idOperacion"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatTiempoTaller"/> class.</returns>
		public abstract PAT.Entities.PatTiempoTaller GetByIdGrupoCatalogoIdOperacion(TransactionManager transactionManager, System.Int16 _idGrupoCatalogo, System.Int32 _idOperacion, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;PatTiempoTaller&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;PatTiempoTaller&gt;"/></returns>
		public static TList<PatTiempoTaller> Fill(IDataReader reader, TList<PatTiempoTaller> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				PAT.Entities.PatTiempoTaller c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("PatTiempoTaller")
					.Append("|").Append((System.Int16)reader[((int)PatTiempoTallerColumn.IdGrupoCatalogo - 1)])
					.Append("|").Append((System.Int32)reader[((int)PatTiempoTallerColumn.IdOperacion - 1)]).ToString();
					c = EntityManager.LocateOrCreate<PatTiempoTaller>(
					key.ToString(), // EntityTrackingKey
					"PatTiempoTaller",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new PAT.Entities.PatTiempoTaller();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.IdGrupoCatalogo = (System.Int16)reader[((int)PatTiempoTallerColumn.IdGrupoCatalogo - 1)];
					c.OriginalIdGrupoCatalogo = c.IdGrupoCatalogo;
					c.IdOperacion = (System.Int32)reader[((int)PatTiempoTallerColumn.IdOperacion - 1)];
					c.OriginalIdOperacion = c.IdOperacion;
					c.TiempoCliente = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoCliente - 1)];
					c.TiempoGarantia = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoGarantia - 1)];
					c.TiempoMecanico = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoMecanico - 1)];
					c.Activo = (System.Boolean)reader[((int)PatTiempoTallerColumn.Activo - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatTiempoTaller"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTiempoTaller"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, PAT.Entities.PatTiempoTaller entity)
		{
			if (!reader.Read()) return;
			
			entity.IdGrupoCatalogo = (System.Int16)reader[((int)PatTiempoTallerColumn.IdGrupoCatalogo - 1)];
			entity.OriginalIdGrupoCatalogo = (System.Int16)reader["ID_GRUPO_CATALOGO"];
			entity.IdOperacion = (System.Int32)reader[((int)PatTiempoTallerColumn.IdOperacion - 1)];
			entity.OriginalIdOperacion = (System.Int32)reader["ID_OPERACION"];
			entity.TiempoCliente = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoCliente - 1)];
			entity.TiempoGarantia = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoGarantia - 1)];
			entity.TiempoMecanico = (System.Decimal)reader[((int)PatTiempoTallerColumn.TiempoMecanico - 1)];
			entity.Activo = (System.Boolean)reader[((int)PatTiempoTallerColumn.Activo - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatTiempoTaller"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTiempoTaller"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, PAT.Entities.PatTiempoTaller entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdGrupoCatalogo = (System.Int16)dataRow["ID_GRUPO_CATALOGO"];
			entity.OriginalIdGrupoCatalogo = (System.Int16)dataRow["ID_GRUPO_CATALOGO"];
			entity.IdOperacion = (System.Int32)dataRow["ID_OPERACION"];
			entity.OriginalIdOperacion = (System.Int32)dataRow["ID_OPERACION"];
			entity.TiempoCliente = (System.Decimal)dataRow["TIEMPO_CLIENTE"];
			entity.TiempoGarantia = (System.Decimal)dataRow["TIEMPO_GARANTIA"];
			entity.TiempoMecanico = (System.Decimal)dataRow["TIEMPO_MECANICO"];
			entity.Activo = (System.Boolean)dataRow["ACTIVO"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatTiempoTaller"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">PAT.Entities.PatTiempoTaller Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, PAT.Entities.PatTiempoTaller entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IdGrupoCatalogoSource	
			if (CanDeepLoad(entity, "PatGrupoCatalogo|IdGrupoCatalogoSource", deepLoadType, innerList) 
				&& entity.IdGrupoCatalogoSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdGrupoCatalogo;
				PatGrupoCatalogo tmpEntity = EntityManager.LocateEntity<PatGrupoCatalogo>(EntityLocator.ConstructKeyFromPkItems(typeof(PatGrupoCatalogo), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdGrupoCatalogoSource = tmpEntity;
				else
					entity.IdGrupoCatalogoSource = DataRepository.PatGrupoCatalogoProvider.GetByIdGrupoCatalogo(transactionManager, entity.IdGrupoCatalogo);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdGrupoCatalogoSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdGrupoCatalogoSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatGrupoCatalogoProvider.DeepLoad(transactionManager, entity.IdGrupoCatalogoSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdGrupoCatalogoSource

			#region IdOperacionSource	
			if (CanDeepLoad(entity, "PatTempario|IdOperacionSource", deepLoadType, innerList) 
				&& entity.IdOperacionSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdOperacion;
				PatTempario tmpEntity = EntityManager.LocateEntity<PatTempario>(EntityLocator.ConstructKeyFromPkItems(typeof(PatTempario), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdOperacionSource = tmpEntity;
				else
					entity.IdOperacionSource = DataRepository.PatTemparioProvider.GetByIdOperacion(transactionManager, entity.IdOperacion);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdOperacionSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdOperacionSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatTemparioProvider.DeepLoad(transactionManager, entity.IdOperacionSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdOperacionSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the PAT.Entities.PatTiempoTaller object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">PAT.Entities.PatTiempoTaller instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">PAT.Entities.PatTiempoTaller Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, PAT.Entities.PatTiempoTaller entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IdGrupoCatalogoSource
			if (CanDeepSave(entity, "PatGrupoCatalogo|IdGrupoCatalogoSource", deepSaveType, innerList) 
				&& entity.IdGrupoCatalogoSource != null)
			{
				DataRepository.PatGrupoCatalogoProvider.Save(transactionManager, entity.IdGrupoCatalogoSource);
				entity.IdGrupoCatalogo = entity.IdGrupoCatalogoSource.IdGrupoCatalogo;
			}
			#endregion 
			
			#region IdOperacionSource
			if (CanDeepSave(entity, "PatTempario|IdOperacionSource", deepSaveType, innerList) 
				&& entity.IdOperacionSource != null)
			{
				DataRepository.PatTemparioProvider.Save(transactionManager, entity.IdOperacionSource);
				entity.IdOperacion = entity.IdOperacionSource.IdOperacion;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PatTiempoTallerChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>PAT.Entities.PatTiempoTaller</c>
	///</summary>
	public enum PatTiempoTallerChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>PatGrupoCatalogo</c> at IdGrupoCatalogoSource
		///</summary>
		[ChildEntityType(typeof(PatGrupoCatalogo))]
		PatGrupoCatalogo,
			
		///<summary>
		/// Composite Property for <c>PatTempario</c> at IdOperacionSource
		///</summary>
		[ChildEntityType(typeof(PatTempario))]
		PatTempario,
		}
	
	#endregion PatTiempoTallerChildEntityTypes
	
	#region PatTiempoTallerFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PatTiempoTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTiempoTaller"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatTiempoTallerFilterBuilder : SqlFilterBuilder<PatTiempoTallerColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerFilterBuilder class.
		/// </summary>
		public PatTiempoTallerFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatTiempoTallerFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatTiempoTallerFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatTiempoTallerFilterBuilder
	
	#region PatTiempoTallerParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PatTiempoTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTiempoTaller"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatTiempoTallerParameterBuilder : ParameterizedSqlFilterBuilder<PatTiempoTallerColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerParameterBuilder class.
		/// </summary>
		public PatTiempoTallerParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatTiempoTallerParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatTiempoTallerParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatTiempoTallerParameterBuilder
	
	#region PatTiempoTallerSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PatTiempoTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatTiempoTaller"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PatTiempoTallerSortBuilder : SqlSortBuilder<PatTiempoTallerColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatTiempoTallerSqlSortBuilder class.
		/// </summary>
		public PatTiempoTallerSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PatTiempoTallerSortBuilder
	
} // end namespace
